- In this slide we will plot a complex function using plotly library
- The algorithm can plot function for power with natural numbers
December 24, 2018
#create the domain
x <- seq(-10,10, length = 21)
iy <- seq(-10i,10i, length = 21)
f <- function(x,iy){
z <- matrix(nrow = length(x), ncol = length(iy))
for(i in 1:length(x)){
for(j in 1:length(iy)){
z[i,j] <- x[i]+iy[j]
}
}
return(z)
}
z <- f(x,iy)
#calculate the function fz <- z^4 #extract the real and imaginary part of the function fx <- Re(fz) fiy <- Im(fz)